/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MembuatLaporan;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Ignacio
 */
public class laporanTabelModel extends AbstractTableModel {

    private List<Laporan> laporanlist = new ArrayList<Laporan>();
//    long sum = 0;

    public laporanTabelModel(List<Laporan> list) {
        this.laporanlist = list;
//        for (int i = 0; i < laporanlist.size(); i++) {
//            sum=sum+laporanlist.get(i).getTotalBeli();
//        }
    }

    @Override
    public int getRowCount() {
        return laporanlist.size();
    }

    @Override
    public int getColumnCount() {
        return 7;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Laporan lapor = laporanlist.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return lapor.getTanggal().substring(0, 10);
            case 1:
                if (lapor.getNoTransBeli().equals("-")) {
                    return lapor.getNoTransJual();
                } else {
                    return lapor.getNoTransBeli();
                }
            case 2:
                return lapor.getTotalBeli();
            case 3:
                return lapor.getTotalJual();
            case 4:
                return lapor.getHargaBeli();
            case 5:
                return lapor.getHargaJual();
            case 6:
                return lapor.getStokPulsa();
//            case 7:
//                return ""+(lapor.getHargaJual()-lapor.getHargaBeli());
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "TANGGAL";
            case 1:
                return "NO TRANSAKSI";
            case 2:
                return "JUMLAH PEMBELIAN";
            case 3:
                return "JUMLAH PENJUALAN";
            case 4:
                return "TOTAL HARGA PEMB";
            case 5:
                return "TOTAL HARGA PENJ";
            case 6:
                return "STOK PULSA";
//            case 7:
//                return "PEMASUKAN";
            default:
                return "";

        }
    }
}
